package com.jingxing.provider;

import org.apache.commons.lang3.StringUtils;

/**
 * @author han
 * @title: RewardReceiveMapperProvider
 * @date 2021/9/15 10:12
 */
public class ReceivingRecordMapperProvider {

    public String getReceivingRecords(String playerName, String prizeName){
        StringBuilder sql = new StringBuilder();
        sql.append("SELECT\n" +
                "\tr.id,\n" +
                "\tr.player_id AS playerId,\n" +
                "\tr.prize_id AS prizeId,\n" +
                "\tp.`name` AS playerName,\n" +
                "\ts.prize_name AS prizeName,\n" +
                "\tr.create_time AS createTime ");
        sql.append("FROM\n" +
                "\treceiving_record AS r\n" +
                "\tLEFT JOIN player_user_info AS p ON r.player_id = p.id\n" +
                "\tLEFT JOIN sign_up_reward AS s ON r.prize_id = s.id ");
        sql.append("WHERE\n" +
                "\tr.del = 0 \n" +
                "\tAND p.del = 0 \n" +
                "\tAND s.del = 0 ");
        if (StringUtils.isNotBlank(playerName)) {
            sql.append("AND p.`name` = '" + playerName + "' ");
        }
        if (StringUtils.isNotBlank(prizeName)) {
            sql.append("AND s.prize_name = '" + prizeName + "' ");
        }
        return sql.toString();
    }
}
